﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class Item : ScriptableObject, IMovable, IDescription
{

    [SerializeField]
    private int stackSize;
    [SerializeField]
    private Sprite icon;
    private slotScript slot;
    [SerializeField]
    private string title;
    [SerializeField]
    private int price;
    
    [SerializeField]
    private Rarity itemRarity;
    public charButton MyCharButton { get; set; }
    public int StackSize { get => stackSize; set => stackSize = value; }
    public Sprite Icon { get => icon; }
    public slotScript Slot { get => slot; set => slot = value; }
    public Rarity MyItemRarity { get => itemRarity;  }
    public string MyTitle { get => title;  }
    public int MyPrice { get => price;}

    public virtual string Description()
    {
        
        return string.Format("<color={0}>{1}</color>",ItemRarityColor.MyRarityColours[MyItemRarity],MyTitle);
    }

    public void ItemDelete()
    {
        if(Slot != null)
        {
            Slot.RemoveItem(this);
            //Slot = null;//try to comment this
        }
    }
}
